package com.example.x3day04.base;

import java.util.ArrayList;

public abstract class BasePresenter<V extends BaseView>  {
    public V mView;
    private ArrayList<BaseModel> mModels = new ArrayList<>();

    public BasePresenter() {
        initModel();
    }

    protected abstract void initModel();

    public void BindView(V view){
        mView = view;
    }

    public void addModel(BaseModel model){
        mModels.add(model);
    }

    public void onDestroy(){
        if (mModels.size() > 0){
            for (int i = 0; i < mModels.size(); i++) {
                mModels.get(i).onDisproy();
                mModels = null;
            }
        }
    }
}
